#include "AfficheurConsole.h"
#include <sstream>
#include "EtatRobotFige.h"
#include "EtatRobotAVideFaceObstacle.h"
#include "EtatRobotEnChargeFaceObstacle.h"
#include "EtatRobotEnCharge.h"


	void AfficheurConsole::miseAJour(){
            

            string descriptionRobot;
            ostringstream oss;
            descriptionRobot += "Robot: X=";
            oss << robot->getPosition()->getx();
            descriptionRobot += oss.str();
            descriptionRobot += " Y=";
            oss.str("");
            oss << robot->getPosition()->gety();
            descriptionRobot += oss.str();
            descriptionRobot += "    Direction:";
            descriptionRobot += robot->getDirection();

            string faceObstacle = "";
            string faceObstacle2 = "";
            if(   robot->getCurrentState() == (EtatRobot*) EtatRobotAVideFaceObstacle::getInstance(robot)
               || robot->getCurrentState() == (EtatRobot*) EtatRobotEnChargeFaceObstacle::getInstance(robot)){
                descriptionRobot += "    Face Obstacle: ";
                oss.str("");
                oss << robot->evaluerObstacle() ;
                descriptionRobot += oss.str();
                faceObstacle = "||";
                faceObstacle2 = "__";
            }else{
                descriptionRobot += "    Voie libre" ;
            }

            string enCharge = " ";
            if(   robot->getCurrentState() == (EtatRobot*) EtatRobotEnCharge::getInstance(robot)
               || robot->getCurrentState() == (EtatRobot*) EtatRobotEnChargeFaceObstacle::getInstance(robot)){
                enCharge = "O";
                descriptionRobot += "    Objet: ";
                oss.str("");
                oss << robot->peser() ;
                descriptionRobot += oss.str();
            }else{
                descriptionRobot += "    Robot à vide";
            }

            string eye = "oo";
            descriptionRobot += "    Etat:";
            if(robot->getCurrentState() != (EtatRobot*) EtatRobotFige::getInstance(robot)){
                descriptionRobot += "en route";
            }else{
                descriptionRobot += "figé";
                eye = "--";
            }

            system("clear");
            cout << "\tMy Little Robot" << endl;

            cout << "\
          ,     ,       \n\
         (\\____/)       \n\
          (_"<< eye <<"_)        \n\
            (O)     "<< enCharge << "  " << faceObstacle2 <<" \n\
          __||__    \\) "<< faceObstacle <<" \n\
       []/______\\[] /  "<< faceObstacle <<" \n\
       / \\______/ \\/   "<< faceObstacle <<" \n\
      /    /__\\        "<< faceObstacle <<" \n\
     (\\   /____\\       "<< faceObstacle <<" \n\
            " << endl;

            cout << descriptionRobot << endl;
            cout << "Press Enter to execute next command" << endl;
            cin.ignore( numeric_limits<streamsize>::max(), '\n' );
        }
		